<template>
	<slot :controller="controller" :store="store" :model="model">
		<AppBasisViewLayout :class="classNames" :openType="openType">
			<template #default>
				<div class="app-de-redirect-view-content">
					<img src="/assets/img/redirect.svg" />
					<div class="context">页面跳转中~</div>
				</div>
			</template>
		</AppBasisViewLayout>
	</slot>
</template>
<script lang="ts" setup>
// 基于template/src/views/{{appModules}}/{{pages@DEREDIRECTVIEW}}/{{spinalCase page.codeName}}-base.vue.hbs生成
import { AppBasisViewLayout } from '@components/layout/basis-view-layout';
import {
	useProps,
	useBasic,
	useAction,
	useController,
} from './sys-department-redirect-view-hook';
import {
	IEvent,
	DERedirectViewActionType,
	IDERedirectViewAbility,
	IDERedirectViewStore,
	IParam,
} from '@/core';

// 输入参数
const props = defineProps(useProps());

// 基础数据
const {
	model,
	getClassNames,
	useNavParamsBind,
	useEventBind,
	handleQuickSearch,
	handleToolbarItemClick,
	handleComponentAction,
	handleCtrlAction,
	handleCtrlInit,
	handleCtrlDestroy,
} = useBasic(props);

const emit = defineEmits<{
	(
		event: 'view-action',
		name: string,
		action: DERedirectViewActionType,
		data: IParam[]
	): void;
	(event: 'view-init', name: string, data: IDERedirectViewAbility): void;
	(event: 'view-mounted', name: string, data: IParam): void;
	(event: 'view-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
	return getClassNames(props);
});

// 初始化控制器
const controller = useController(props, evt);

useNavParamsBind(controller, props);

const store: IDERedirectViewStore = controller.getStore();

onMounted(() => {
	controller.viewMounted();
});

onUnmounted(() => {
	controller.viewDestroy();
});
</script>
